import type { AxiosOperator } from '@/common/infrastructure/axios_operator.ts'
import type { LoginInfo } from '@/common/model/app/login_info'

export class AuthenticationApi {
  // 请求操作者
  private _requestOperator: AxiosOperator

  // 请求路由
  private controller: string = '/Authentication'

  /**
   * 有参构造方法
   * @param requestOperator 请求操作者
   * */
  constructor(requestOperator: AxiosOperator) {
    this._requestOperator = requestOperator
  }

  //region # 登录 —— login(loginId: string...)
  /**
   * 登录
   * @param loginId 用户名
   * @param password 密码
   * */
  public async login(loginId: string, password: string): Promise<LoginInfo> {
    return await this._requestOperator.post(`${this.controller}/Login`, {
      loginId,
      password,
    })
  }

  //endregion
}
